package Bubble;

import java.awt.Point;
import java.awt.image.BufferedImage;
import java.util.LinkedList;

import Part.Part;
import Part.PartBub;
import Part.Parts;
import PathPoint.Path;

import com.golden.gamedev.Game;
/**
 * A class holding bubbles to shoot
 * @author Yin
 *
 */
public class BubbleShot extends Bubbles
{
	
	private BufferedImage PART_BUB_IMG;
    private BufferedImage SM_FISH_IMG;
    private final int RAD_BUBBLE = 13;
    private int myEpisode;

	public BubbleShot(Game game, int episode, Path path, Parts parts)
	{
		super(game, path, parts);
		myEpisode = episode;
		Bubble bub = super.getRandomBubble(true, myEpisode, new LinkedList<Bubble>());
		bub.setLocation(path.getPathPoint(0).x, path.getPathPoint(0).y);
		add(bub);
		add(super.getRandomBubble(true, myEpisode, new LinkedList<Bubble>()));
		add(super.getRandomBubble(true, myEpisode, new LinkedList<Bubble>()));
		
		PART_BUB_IMG = game.getImage("resources/part_bub_01.png");
		SM_FISH_IMG = game.getImage("resources/smfish.png");
	}
	
	/**
	 * Set location for the bubble with given index
	 * @param index
	 * @param x
	 * @param y
	 */
	public void setLocation(int index, double x, double y)
	{
		getList().get(index).setLocation(x, y);
	}
	
	/**
	 * Shoot a bubble
	 * Remove first bubble from the list
	 * Add a new one to the end of the list
	 * @return the shot bubble
	 */
	public Bubble shoot()
	{
		add(super.getRandomBubble(true, myEpisode, new LinkedList<Bubble>()));
		remove(0);
		return getList().poll();
	}
	
	/**
	 * Swap last two bubbles when right click
	 */
	public void swap()
	{
		Bubble lastBub = getList().removeLast();
		Bubble lastBub2 = getList().removeLast();
		getList().addLast(lastBub);
		getList().addLast(lastBub2);
	}
	
}
